/**
 * 静态路由配置
 */
// @ 是 src 目录的绝对路径别名
const Home = () => import('@/views/home')
const Cart = () => import('@/views/cart')
const Category = () => import('@/views/category/index.vue')
const Confirm = () => import('@/views/confirm')
const Detail = () => import('@/views/detail')
const DetailFooter = () => import('@/views/detail/footer')
const Login = () => import('@/views/login')
const Mine = () => import('@/views/mine')
const Register = () => import('@/views/register/index.vue')
const TabBar = () => import('@/components/tab-bar/index.vue')
const SubCategory = () => import('@/views/category/SubCategory.vue')
const Popularity = () => import('@/views/popularity/popularity.vue')

const routes = [
  {
    path: '/',
    redirect: '/home',
    meta: {},
  },
  {
    path: '/home',
    components: { // 与命名视图对象
      default: Home,
      footer: TabBar,
    },
    meta: {
      icon: '&#xe619;', // tabbar 项的图标
      title: '首页', // 标题
      inTabBar: true, // 在 tabbar 中
      noBack: true, // 不可返回（无返回按钮）
      replace: true, // 路由导航（replace()）
    },
  },
  {
    path: '/category',
    redirect: '/category/sub/00036',
    components: { // 与命名视图对象
      default: Category,
      footer: TabBar,
    },
    children: [
      {
        path: 'sub/:id', // 完整路径: /category/sub/
        components: {
          default: SubCategory,
        },
        meta: {
          title: '分类',
        },
      },
    ],
    meta: {
      icon: '&#xe61a;',
      title: '分类',
      inTabBar: true,
      noBack: true,
      replace: true,
    },
  },
  {
    path: '/cart',
    components: { // 与命名视图对象
      default: Cart,
      footer: TabBar,
    },
    meta: {
      icon: '&#xe61b;',
      title: '购物车',
      inTabBar: true,
    },
  },
  {
    path: '/confirm',
    components: {
      default: Confirm,
    },
    meta: {
      title: '确认订单',
    },
  },
  {
    path: '/detail',
    components: {
      default: Detail,
      footer: DetailFooter,
    },
    meta: {
      title: '商品详情',
    },
  },
  {
    path: '/login',
    components: {
      default: Login,
    },
    meta: {
      title: '用户登录',
    },
  },
  {
    path: '/mine',
    components: { // 与命名视图对象
      default: Mine,
      footer: TabBar,
    },
    meta: {
      icon: '&#xe61c;',
      title: '我的',
      inTabBar: true,
      noBack: true,
      replace: true,
    },
  },
  {
    path: '/popularity',
    components: {
      default: Popularity,
    },
    meta: {
      title: '人气榜单',
    },
  },
  {
    path: '/register',
    components: {
      default: Register,
    },
    meta: {
      title: '用户注册',
    },
  },
]

export default routes
